

ac.item('专属装备'){
    art = [[ReplaceableTextures\CommandButtons\BTNArcaniteMelee.blp]],
    drop_flag = false,
    item_level = 0,
    base_tip = '暂无',
    tip = [[属性：|n'base_tip'|n|n'up_tip']],
    get_lumber = function(self)
        return (self.item_level + 1) * 100
    end,
    up_tip = function(self)
        if self.count>0 then
            return '使用次数为0时点击挑战Boss升级'
        end
        local lumber = self:get_lumber()
        return ('点击花费|cff00ff00%0.f|r金币升级'):format(lumber)
    end,
    on_get = function(self)
        local hero = self.owner
        local player = hero.owner
        self.show_timer = ac.loop(200,function()
            local lumber = self:get_lumber()
            self.show_effect = player:get('金币')>=lumber
        end)
        self:gc(self.show_timer)
    end,
    on_use = function(self)
        local hero = self.owner
        local player = hero.owner
        local lumber = self:get_lumber()
        if self.item_level>=10 then
            if self.count>0 then
                return
            end
            
            local level = self.item_level + 1
            local zdl = (level + 1)*level/2 * 30
            local unit = player:create_enemy('巨型骷髅',nil,zdl)
            unit.title = '专属升级'
            unit:add_buff '挑战限时'{time = 30}
            unit:event '单位-死亡'(function()
                self:set_lv(level)
            end)
            return
        end

        if player:get('金币')<lumber then
            show_item_tip(player,self,'金币')
            return
        end
        player:add('金币',-lumber)
        show_item_tip(player,self,'刷新')
        show_item_tip(player,self,'成功')

        self:set_lv(self.item_level + 1)
    end,
    set_lv = function(self,level)
        local hero = self.owner
        local player = hero.owner

        --属性处理
        self.item_level = level
        self.state = self.state or {}
        LoadItemSX(hero,self.state,-1)

        self.state['多重数量'] = math.ceil(level/5)
        if self.item_level<10 then
            self.state['基础攻击'] = 100 * level
            self.state['全属性'] = 100 * level
            self.title = ('专属Lv%s'):format(level)
        else
            local ex = (level - 9)
            local sx = 500 + ex * 500
            self.state['基础攻击'] = sx
            self.state['全属性'] = sx
            self:set_count(500 + 100 * ex)
            if self.item_level==10 then
                self.show_timer:remove()
                hero:event '英雄-击杀单位'(function()
                    self:add_count(-1)
                    self.show_effect = self:get_count()==0
                end)
            end
        end
        self.base_tip = atts_tip(self.state)
        LoadItemSX(hero,self.state,1)

        if level>0 then
            hero:notify('英雄-选择专属词条',hero,self)
        end
        if level==3 then
            player:notify('玩家-显示商店',player,'装备抽取',0.5)
        end
        if level==6 then
            player:notify('玩家-显示商店',player,'杀敌兑换',0.5)
        end
        if level==9 then
            player:notify('玩家-显示商店',player,'闹鬼金矿',0.5)
        end
    end,
}

local excel = {
    '金币获取','杀敌获取',
    '攻击速度','冷却速度',
    '物理伤害','魔法伤害',
    '普攻输出','技能输出',
    '物理穿透','法术穿透',
    '普攻爆伤','技能爆伤',
}

ac.game:event '英雄-选择专属词条'(function(_,hero,item)
    local player = hero.owner
    local info = {}
    local lv = math.ceil(item.item_level/3)
    local max = 4 + lv * 2
    for a,name in ipairs(excel) do
        if a<=max and a>max-10 then
            local num = 10
            local tip = sx_tip(name,num)
            info[#info + 1] = {
                title = tip,
                key = name,
                num = num
            }
        end
    end
    local data = table.random_table(info,3)

    player:notify('玩家-添加专属词条',player,data,function(temp,index)
        local key = temp.key
        local num = temp.num
        
        LoadItemSX(hero,item.state,-1)
        item.state[key] = (item.state[key] or 0) + num
        item.base_tip = atts_tip(item.state)
        LoadItemSX(hero,item.state,1)
    end)
end)


register_hero(function(player,hero)
    hero:add_item('专属装备',{owner_player = player})
    player:add('金币',100)
end)
